#! python
# -*- coding: utf-8 -*-
"""
@File Name: 将计算器作为一个部件嵌入到别的GUI中.py
@Author: LT
@Date: 2021/10/27 14:21
# -----------------------------------------------------------------------------------------------------
@Description: 
write here
# -----------------------------------------------------------------------------------------------------
"""
from tkinter import *
import sys, os
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
__package__ = os.path.split(os.path.dirname(__file__))[-1]
from .计算器_calculator import CalcGui


def calcContainer(parent=None):
    frm = Frame(parent)
    frm.pack(expand=YES, fill=BOTH)
    Label(frm, text="Calc Container").pack(side=TOP)
    CalcGui(frm)
    Label(frm, text="Calc Container").pack(side=BOTTOM)
    return frm


class calcSubclass(CalcGui):
    def makeWidgets(self, fg, bg, font):
        Label(self, text='Calc Subclass').pack(side=TOP)
        Label(self, text='Calc Subclass').pack(side=BOTTOM)
        CalcGui.makeWidgets(self, fg, bg, font)


if __name__ == '__main__':
    import sys
    if len(sys.argv) == 1:
        root = Tk()                                                 # 在同一个进程中运行3个计算器
        CalcGui(Toplevel())                                         # 每个都创建一个新的顶级窗口
        calcContainer(Toplevel())
        calcSubclass(Toplevel())
        Button(root, text='quit', command=root.quit).pack()
        root.mainloop()
    elif len(sys.argv) == 2:
        CalcGui().mainloop()                                        # 作为独立窗口
    elif len(sys.argv) == 3:
        calcContainer().mainloop()                                  # 作为嵌入的部件
    elif len(sys.argv) == 4:
        calcSubclass().mainloop()                                   # 作为定制过的超类
